<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
		"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:components="http://java.sun.com/jsf/composite/components"
>
<h:head>
</h:head>

<h:body>
    <h1>Reproducer for dynamic composite component inclusion problem</h1>

    <h2>How to NOT reproduce</h2>

    <p>
        Enable components one by one in ascending order by clicking the buttons in any of the following sequences:
    </p>
    <ul>
        <li>1, 2</li>
        <li>1, 2, 3</li>
        <li>2, 3</li>
    </ul>

    <h2>How to reproduce</h2>

    <p>
        Enable components one by one in descending order. All of these cause an error:
    </p>
    <ul>
        <li>3, 2</li>
        <li>2, 1</li>
    </ul>

    <div style="border: 1px solid #AAA; background-color: #FAFAFA; padding: 20px">
		<!--
		   - For some reason this forEach construction works, although the resulting component tree
		   - should be identical to the unrolled facelet below!?
		   -
		<h:form>
			<c:forEach begin="1" end="3" varStatus="loop">
				<components:button id="button_${loop.index}" idx="${loop.index}"/>
				<c:if test="${includeBean.isVisible(loop.index)}">
					<components:comp id="included_${loop.index}" idx="${loop.index}"/>
				</c:if>
			</c:forEach>
		</h:form>
		-->

		<h:form>
			<components:button id="button_1" idx="1"/>
			<c:if test="${includeBean.isVisible(1)}">
				<components:comp id="included_1" idx="1"/>
			</c:if>

			<components:button id="button_2" idx="2"/>
			<c:if test="${includeBean.isVisible(2)}">
				<components:comp id="included_2" idx="2"/>
			</c:if>

			<components:button id="button_3" idx="3"/>
			<c:if test="${includeBean.isVisible(3)}">
				<components:comp id="included_3" idx="3"/>
			</c:if>
		</h:form>
    </div>
</h:body>
</html>
